﻿using Maticsoft.DBUtility;
using System;
using System.Data;
using System.IO;
using System.Web.UI.HtmlControls;
using Utils;

public partial class WebPage_Index_ShujuBeifen : SystemBBasePage
{
    protected bool backup = true;
    protected DataTable selectoptions = new DataTable();

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "index";
        this.Index1.Select = "Index_ShujuBeifen";
        if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "backup.bk"))
        {
            this.backup = false;
        }
        this.selectoptions.Columns.Add(new DataColumn("text", System.Type.GetType("System.String")));
        this.selectoptions.Columns.Add(new DataColumn("value", System.Type.GetType("System.String")));
        this.selectoptions = DbHelperSQL.Query("select name as text,name as value from sysobjects where xtype='U' order by text").Tables[0];
        DataRow row = this.selectoptions.NewRow();
        row["text"] = "请选择数据表";
        row["value"] = "";
        this.selectoptions.Rows.InsertAt(row, 0);
        if (base.Request["buttontype"] == "开始备份")
        {
            if (Helper.GetString(base.Request["bfzl"], string.Empty) == "all")
            {
                WebSiteHelper.BackUpAll();
                base.SetSuccess("备份成功");
            }
            else
            {
                string tablename = Helper.GetString(base.Request["tablename"], string.Empty);
                if (tablename.Length > 0)
                {
                    WebSiteHelper.BackUpSingle(tablename);
                    base.SetSuccess("备份成功");
                }
                else
                {
                    this.SetError("数据表选择错误");
                }
            }
        }
    }
}


